﻿using AVCUMPlatform.Model;

namespace AVCUMPlatform.ReadMqConfig
{
    /// <summary>
    /// 读取Mq配置
    /// </summary>
    public class ReadMqConfigHelper
    {
        /// <summary>
        /// 读取配置文件
        /// </summary>
        /// <returns></returns>
        public static List<MqConfigInfo> ReadMqConfig(IConfiguration configuration)
        {
            try
            {
                List<MqConfigInfo> config = new List<MqConfigInfo>();
                MqConfigInfo configInfo = new MqConfigInfo();
                configuration.GetSection("RabbitMQOption").Bind(configInfo);
                config.Add(configInfo);

                if (config.Any())
                {
                    return config;
                }
                Console.WriteLine($"获取MQ配置信息失败：没有可用数据集");
                return null;
            }
            catch (Exception ex)
            {
                Console.WriteLine($"获取MQ配置信息失败：{ex.Message}");
                return null;
            }
        }
    }
}
